package com.ludomancy.breathe;

import java.util.Collection;
import java.util.Iterator;

public class Bruno
{
	public double trust = 0.3;
	private String speech = "";
	private PsycheGraph psyche;
	public PsycheNode nightmares;
	
	public Bruno()
	{
		speech = "I want to get rid of the nightmares";
		
		psyche = PsycheLoader.load();
		nightmares = psyche.getNode("nightmares");
	}
	
	public String getObservation()
	{
		if(trust <= 0)
		{
			return "Bruno stares coldly at you. He seems resolute.";
		}
		if(trust < 0.2)
		{
			return "Bruno is uncomfortable. You can tell he doesn't trust you.";
		}
		if(trust < 0.5)
		{
			return "Bruno is showing a hint of hope in his eyes. His insecurity is fading a bit."; 
		}
		else
		{
			return "Bruno looks relaxed.";
		}
	}
	
	public String processOption(Option option)
	{
		// describe that option and offer the neighbors
		Collection targets = psyche.getNeighbors(option.node);
		speech = option.node.desc;
		for (Iterator iter = targets.iterator(); iter.hasNext();)
		{
			PsycheNode node = (PsycheNode) iter.next();
			if(node != option.node)
			{
				// get our link
				double weight = psyche.getWeight(node, option.node);
				if((node.threat * weight) < trust)
				{
					if(!Game.game.hasOption(new Option(node)))
					{
						Game.game.addOption(new Option(node));
						trust += 0.1;
					}
				}
			}
		}
		return option.node.desc;
	}
	
	public String getSpeech()
	{
		return speech;
	}
}
